<template>
	<view>
		<web-view :src="url"></web-view>
	</view>
</template>
 
<script>
	import commonApi from '@/utils/commonMethod.js';
	export default {
		data() {
			return {
				url: '',
				bookId: '',
				sampleBook:{},
			};
		},
		async onLoad(options) {
			console.log(options);
		    this.url = decodeURIComponent(options.url)
			this.bookId = decodeURIComponent(options.bookId)
      if(this.bookId != null && this.bookId != '' && this.bookId != "undefined") {
        await this.getSampleBook()
      }
		},
		/*分享朋友圈 */
		onShareTimeline: function() {
			return {
				title: this.sampleBook.bookName,
				query: '',
				imageUrl: this.sampleBook.imageUrl,
			}
		},
		onShareAppMessage: function () {//分享
			return {
				title: this.sampleBook.bookName,
				path: '/components/webview/webview?url=' + encodeURIComponent(this.url),
				desc: this.sampleBook.bookName,
				imageUrl: this.sampleBook.imageUrl,
				success: function (res) {
					console.info(res + '成功');
					wx.showToast({
						title: '分享成功',
					})
					// 转发成功
				},
				fail: function (res) {
					console.log(res + '失败');
					// 转发失败
				},
			 
			}
		 },
		 methods: {
			 getSampleBook(){
			 	commonApi.getSampleBook(this.bookId).then(res =>{
					this.sampleBook = res.data.nocSampleBook
				})
			 }
		 }
		
	}
</script>
 
<style lang="scss">
	
</style>
